package com.vgulu.server.login.controller;

import com.vgulu.server.common.TConstant;
import com.vgulu.server.common.bean.KeyValue;
import com.vgulu.server.common.bean.VResponse;
import com.vgulu.server.common.exception.VBaseException;
import com.vgulu.server.login.bean.UidBean;
import com.vgulu.server.login.repository.entity.Uid;
import com.vgulu.server.login.service.UserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by wangchunsee on 16/10/4.
 */
@Controller
@RequestMapping("/pass")
public class CheckController {
    private static final Logger logger = LoggerFactory.getLogger(ModifyPwdController.class);
    @Autowired
    UserService userService;

    @RequestMapping("/checkToken")
    @ResponseBody
    public VResponse<Uid> checkToken(@RequestParam("token") String token){
        try{
            Uid uid=userService.checkToken(token);
            return VResponse.success(uid);
        }catch (VBaseException e){
            logger.error(VBaseException.TAG,e);
            return VResponse.error(e);
        }catch (Throwable e){
            logger.error(TConstant.LOGTAG_UNCATCH_EXCEPTION,e);
            return VResponse.error(e);
        }
    }
}
